# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=opensips
pkgver=3.3.5
pkgrel=1
pkgdesc="An Open Source SIP Server able to act as a SIP proxy, registrar, location server, redirect server ..."
url="https://www.opensips.org"
depends=('gcc-libs')
makedepends=('libldap' 'libmariadbclient' 'libmicrohttpd' 'libxml2' 'libxslt'
             'lynx' 'openssl' 'postgresql-libs' 'unixodbc')
optdepends=('curl: db_http module'
            'libldap: ldap module'
            'libmicrohttpd: httpd module'
            'libxml2: presence module'
            'mariadb-libs: db_mysql module'
            'openssl: tls_openssl module'
            'postgresql-libs'
            'unixodbc: db_unixodbc module')
backup=("etc/opensips/opensips.cfg"
	"etc/opensips/osipsconsolerc"
	"etc/opensips/opensipsctlrc")
arch=('loong64' 'x86_64')
license=('GPL')
options=('!emptydirs' '!makeflags')
source=(https://opensips.org/pub/opensips/${pkgver}/opensips-${pkgver}.tar.gz
	opensips.service)
sha256sums=('77333d1b4730f0aa2f1fb994741b5bfb7c922a58b7f81cc4e35e8b25394a9637'
            'c2fec4be085b108db10834fa9832e98d696c2de6408f85f96cf89c13bf6be819')

_modules="db_http db_mysql db_postgres db_unixodbc h350 httpd ldap presence presence_xml proto_tls tls_mgm tls_openssl tm rr"

build() {
  cd "$srcdir"/$pkgname-$pkgver/

  make \
	include_modules="${_modules}" bin_dir=bin/ cfg_target=/etc/$pkgname/ \
	LIBDIR=lib PREFIX=/usr
}

package() {
  cd "$srcdir"/$pkgname-$pkgver/

  make \
	include_modules="${_modules}" bin_dir=bin/ cfg_target=/etc/$pkgname/ cfg_prefix="$pkgdir" \
	BASEDIR="$pkgdir" PREFIX=/usr LIBDIR=lib install

  install -Dm0644 "$srcdir"/$pkgname.service "$pkgdir"/usr/lib/systemd/system/$pkgname.service
}
